#ifndef _PANEL_
#define _PANEL_

#include "Object.h"

#include "..\Core\base.h"

#include <iostream>

using namespace std;

namespace air {
	class SceneManager;
	struct Event;

	/**
	 * @brief Gui Container
     */
	class Panel: public IGuiObject
	{
	public:
		/**
		 * @brief constructor initialize position and size
		 */
		Panel(hgeResourceManager* hgeResMan, float x, float y, float w, float h);
		/*Panel(hgeResourceManager* hgeResMan ,float x, float y, float w, float h);
		Panel(hgeResourceManager* hgeResMan ,float sx, float sy, float dx, float dy, float w, float h);*/
		/**
		 * @brief destructor release hgeSprite
		 */
		~Panel();

		void SetTransfromationTween(float dx, float dy, float dt, Event* _evnt = NULL);
		
		/**
		 * @brief override original move method. move panel along with all GUI Objects attached with panel
		 */
		//void moveTo(float x, float y);

		/**
		 * @brief add a panel with inner GuiObject to Gui, must be called when using a panel
		 *
		 * @param SceneManager SceneManager for call SceneManager->addGuiObject
		 * @param specify the anchor of its subordinate GuiObject as well as itself
		 *
		 * @return true when all elements are added successfully, otherwise false
		 */
		bool addToGui(SceneManager*, IGuiObject* anchor = NULL);
		/**
		 * @brief place other GUIObject(Panel included) in panel by percent 
		 *
		 * @param IGuiObject pointer to GUIObject
		 * @param px relative horizontal position(by percent)
		 * @param py relative vertical position(percent)
		 */
		void placeGuiObjectProportional(IGuiObject*, float px, float py);
		/**
		 * @brief place other GUIObject(Panel included) in panel by absolute offset position
		 *
		 * @param IGuiObject pointer to GUIObject
		 * @param x relative horizontal position
		 * @param y relative vertial position
		 */
		void placeGuiObjectOffset(IGuiObject*, float x, float y);

		virtual void Update(float dt);
		virtual void Render();
		/**
		 * @brief slide the panel into screen
		 */
		//virtual void Enter() {	status = 1;	}
		/**
		 * @brief slide the panel out of the screen
		 */
		//virtual void Leave() {	status = 2;	}
		/**
		 * @brief whether slide in/out is complete
		 *
		 * @return true for complete, otherwise false
		 */
		//virtual bool IsDone();

	private:
		/**
		 * @brief container of all the GUIObject placed in the container
		 */
		Alist<IGuiObject*> container;
		/**
		 * @brief basic frame for panel
		 */
		hgeSprite *frame;
		/*
		 * @brief special visual effect for panel
		 */
		hgeSprite *flash;
		float framex, framey, flashw, flashh;
		float width, height;
		/**
		 * @brief current status of panel, 1 for sliding in, 2 for sliding out, 0 for static
		 */

		float sx, sy;
		float dx, dy;
		float vx, vy;

		float time;
		int status;
		Event* callback;
	};
}



#endif
